<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Class: I18n::Backend::Simple</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Class</strong></td>
          <td class="class-name-in-header">I18n::Backend::Simple</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../../files/vendor/rails/activerecord/lib/active_record/i18n_interpolation_deprecation_rb.html">
                vendor/rails/activerecord/lib/active_record/i18n_interpolation_deprecation.rb
                </a>
        <br />
                <a href="../../../files/vendor/rails/activesupport/lib/active_support/vendor/i18n-0_0_1/i18n/backend/simple_rb.html">
                vendor/rails/activesupport/lib/active_support/vendor/i18n-0.0.1/i18n/backend/simple.rb
                </a>
        <br />
            </td>
        </tr>

        <tr class="top-aligned-row">
            <td><strong>Parent:</strong></td>
            <td>
                <a href="../../Object.html">
                Object
               </a>
            </td>
        </tr>
        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">



   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M002256">deep_symbolize_keys</a>&nbsp;&nbsp;
      <a href="#M002249">default</a>&nbsp;&nbsp;
      <a href="#M002246">init_translations</a>&nbsp;&nbsp;
      <a href="#M002244">initialized?</a>&nbsp;&nbsp;
      <a href="#M002251">interpolate</a>&nbsp;&nbsp;
      <a href="#M002239">interpolate_with_deprecated_syntax</a>&nbsp;&nbsp;
      <a href="#M002252">load_file</a>&nbsp;&nbsp;
      <a href="#M002253">load_rb</a>&nbsp;&nbsp;
      <a href="#M002240">load_translations</a>&nbsp;&nbsp;
      <a href="#M002254">load_yml</a>&nbsp;&nbsp;
      <a href="#M002243">localize</a>&nbsp;&nbsp;
      <a href="#M002248">lookup</a>&nbsp;&nbsp;
      <a href="#M002255">merge_translations</a>&nbsp;&nbsp;
      <a href="#M002250">pluralize</a>&nbsp;&nbsp;
      <a href="#M002245">reload!</a>&nbsp;&nbsp;
      <a href="#M002241">store_translations</a>&nbsp;&nbsp;
      <a href="#M002242">translate</a>&nbsp;&nbsp;
      <a href="#M002247">translations</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">


    <div id="constants-list">
      <h3 class="section-bar">Constants</h3>

      <div class="name-list">
        <table summary="Constants">
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">DEPRECATED_INTERPOLATORS</td>
          <td>=</td>
          <td class="context-item-value">{ '%d' =&gt; '{{count}}', '%s' =&gt; '{{value}}' }</td>
        </tr>
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">INTERPOLATION_RESERVED_KEYS</td>
          <td>=</td>
          <td class="context-item-value">%w(scope default)</td>
        </tr>
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">MATCH</td>
          <td>=</td>
          <td class="context-item-value">/(\\\\)?\{\{([^\}]+)\}\}/</td>
        </tr>
        </table>
      </div>
    </div>



      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M002244" class="method-detail">
        <a name="M002244"></a>

        <div class="method-heading">
          <a href="#M002244" class="method-signature">
          <span class="method-name">initialized?</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M002244-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M002244-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/vendor/i18n-0.0.1/i18n/backend/simple.rb, line 68</span>
68:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialized?</span>
69:         <span class="ruby-ivar">@initialized</span> <span class="ruby-operator">||=</span> <span class="ruby-keyword kw">false</span>
70:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M002240" class="method-detail">
        <a name="M002240"></a>

        <div class="method-heading">
          <a href="#M002240" class="method-signature">
          <span class="method-name">load_translations</span><span class="method-args">(*filenames)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Accepts a list of paths to translation files. Loads <a
href="Simple.html#M002247">translations</a> from plain Ruby (*.rb) or YAML
files (*.yml). See <a href="Simple.html#M002253">load_rb</a> and <a
href="Simple.html#M002254">load_yml</a> for details.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M002240-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M002240-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/vendor/i18n-0.0.1/i18n/backend/simple.rb, line 12</span>
12:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">load_translations</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">filenames</span>)
13:         <span class="ruby-identifier">filenames</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">filename</span><span class="ruby-operator">|</span> <span class="ruby-identifier">load_file</span>(<span class="ruby-identifier">filename</span>) }
14:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M002243" class="method-detail">
        <a name="M002243"></a>

        <div class="method-heading">
          <a href="#M002243" class="method-signature">
          <span class="method-name">localize</span><span class="method-args">(locale, object, format = :default)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Acts the same as <tt>strftime</tt>, but returns a localized version of the
formatted date string. Takes a key from the date/time formats <a
href="Simple.html#M002247">translations</a> as a format argument
(<em>e.g.</em>, <tt>:short</tt> in <tt>:&#8217;date.formats&#8216;</tt>).
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M002243-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M002243-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/vendor/i18n-0.0.1/i18n/backend/simple.rb, line 48</span>
48:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">localize</span>(<span class="ruby-identifier">locale</span>, <span class="ruby-identifier">object</span>, <span class="ruby-identifier">format</span> = <span class="ruby-identifier">:default</span>)
49:         <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-node">&quot;Object must be a Date, DateTime or Time object. #{object.inspect} given.&quot;</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">object</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:strftime</span>)
50:         
51:         <span class="ruby-identifier">type</span> = <span class="ruby-identifier">object</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:sec</span>) <span class="ruby-operator">?</span> <span class="ruby-value str">'time'</span> <span class="ruby-operator">:</span> <span class="ruby-value str">'date'</span>
52:         <span class="ruby-comment cmt"># TODO only translate these if format is a String?</span>
53:         <span class="ruby-identifier">formats</span> = <span class="ruby-identifier">translate</span>(<span class="ruby-identifier">locale</span>, <span class="ruby-node">&quot;#{type}.formats&quot;</span><span class="ruby-node">&quot;#{type}.formats&quot;</span>)
54:         <span class="ruby-identifier">format</span> = <span class="ruby-identifier">formats</span>[<span class="ruby-identifier">format</span>.<span class="ruby-identifier">to_sym</span>] <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">formats</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">formats</span>[<span class="ruby-identifier">format</span>.<span class="ruby-identifier">to_sym</span>]
55:         <span class="ruby-comment cmt"># TODO raise exception unless format found?</span>
56:         <span class="ruby-identifier">format</span> = <span class="ruby-identifier">format</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">dup</span>
57: 
58:         <span class="ruby-comment cmt"># TODO only translate these if the format string is actually present</span>
59:         <span class="ruby-comment cmt"># TODO check which format strings are present, then bulk translate then, then replace them</span>
60:         <span class="ruby-identifier">format</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-regexp re">/%a/</span>, <span class="ruby-identifier">translate</span>(<span class="ruby-identifier">locale</span>, <span class="ruby-value str">&quot;date.abbr_day_names&quot;</span><span class="ruby-value str">&quot;date.abbr_day_names&quot;</span>)[<span class="ruby-identifier">object</span>.<span class="ruby-identifier">wday</span>]) 
61:         <span class="ruby-identifier">format</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-regexp re">/%A/</span>, <span class="ruby-identifier">translate</span>(<span class="ruby-identifier">locale</span>, <span class="ruby-value str">&quot;date.day_names&quot;</span><span class="ruby-value str">&quot;date.day_names&quot;</span>)[<span class="ruby-identifier">object</span>.<span class="ruby-identifier">wday</span>])
62:         <span class="ruby-identifier">format</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-regexp re">/%b/</span>, <span class="ruby-identifier">translate</span>(<span class="ruby-identifier">locale</span>, <span class="ruby-value str">&quot;date.abbr_month_names&quot;</span><span class="ruby-value str">&quot;date.abbr_month_names&quot;</span>)[<span class="ruby-identifier">object</span>.<span class="ruby-identifier">mon</span>])
63:         <span class="ruby-identifier">format</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-regexp re">/%B/</span>, <span class="ruby-identifier">translate</span>(<span class="ruby-identifier">locale</span>, <span class="ruby-value str">&quot;date.month_names&quot;</span><span class="ruby-value str">&quot;date.month_names&quot;</span>)[<span class="ruby-identifier">object</span>.<span class="ruby-identifier">mon</span>])
64:         <span class="ruby-identifier">format</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-regexp re">/%p/</span>, <span class="ruby-identifier">translate</span>(<span class="ruby-identifier">locale</span>, <span class="ruby-node">&quot;time.#{object.hour &lt; 12 ? :am : :pm}&quot;</span><span class="ruby-node">&quot;time.#{object.hour &lt; 12 ? :am : :pm}&quot;</span>)) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">object</span>.<span class="ruby-identifier">respond_to?</span> <span class="ruby-identifier">:hour</span>
65:         <span class="ruby-identifier">object</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-identifier">format</span>)
66:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M002245" class="method-detail">
        <a name="M002245"></a>

        <div class="method-heading">
          <a href="#M002245" class="method-signature">
          <span class="method-name">reload!</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M002245-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M002245-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/vendor/i18n-0.0.1/i18n/backend/simple.rb, line 72</span>
72:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">reload!</span>
73:         <span class="ruby-ivar">@initialized</span> = <span class="ruby-keyword kw">false</span>
74:         <span class="ruby-ivar">@translations</span> = <span class="ruby-keyword kw">nil</span>
75:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M002241" class="method-detail">
        <a name="M002241"></a>

        <div class="method-heading">
          <a href="#M002241" class="method-signature">
          <span class="method-name">store_translations</span><span class="method-args">(locale, data)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Stores <a href="Simple.html#M002247">translations</a> for the given locale
in memory. This uses a deep merge for the <a
href="Simple.html#M002247">translations</a> hash, so existing <a
href="Simple.html#M002247">translations</a> will be overwritten by new ones
only at the deepest level of the hash.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M002241-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M002241-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/vendor/i18n-0.0.1/i18n/backend/simple.rb, line 20</span>
20:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">store_translations</span>(<span class="ruby-identifier">locale</span>, <span class="ruby-identifier">data</span>)
21:         <span class="ruby-identifier">merge_translations</span>(<span class="ruby-identifier">locale</span>, <span class="ruby-identifier">data</span>)
22:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M002242" class="method-detail">
        <a name="M002242"></a>

        <div class="method-heading">
          <a href="#M002242" class="method-signature">
          <span class="method-name">translate</span><span class="method-args">(locale, key, options = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M002242-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M002242-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/vendor/i18n-0.0.1/i18n/backend/simple.rb, line 24</span>
24:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">translate</span>(<span class="ruby-identifier">locale</span>, <span class="ruby-identifier">key</span>, <span class="ruby-identifier">options</span> = {})
25:         <span class="ruby-identifier">raise</span> <span class="ruby-constant">InvalidLocale</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">locale</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">locale</span>.<span class="ruby-identifier">nil?</span>
26:         <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">key</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">k</span><span class="ruby-operator">|</span> <span class="ruby-identifier">translate</span>(<span class="ruby-identifier">locale</span>, <span class="ruby-identifier">k</span>, <span class="ruby-identifier">options</span>) } <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">key</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">Array</span>
27: 
28:         <span class="ruby-identifier">reserved</span> = <span class="ruby-identifier">:scope</span>, <span class="ruby-identifier">:default</span>
29:         <span class="ruby-identifier">count</span>, <span class="ruby-identifier">scope</span>, <span class="ruby-identifier">default</span> = <span class="ruby-identifier">options</span>.<span class="ruby-identifier">values_at</span>(<span class="ruby-identifier">:count</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">reserved</span>)
30:         <span class="ruby-identifier">options</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">:default</span>)
31:         <span class="ruby-identifier">values</span> = <span class="ruby-identifier">options</span>.<span class="ruby-identifier">reject</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span> <span class="ruby-identifier">reserved</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">name</span>) }
32: 
33:         <span class="ruby-identifier">entry</span> = <span class="ruby-identifier">lookup</span>(<span class="ruby-identifier">locale</span>, <span class="ruby-identifier">key</span>, <span class="ruby-identifier">scope</span>)
34:         <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">entry</span>.<span class="ruby-identifier">nil?</span>
35:           <span class="ruby-identifier">entry</span> = <span class="ruby-identifier">default</span>(<span class="ruby-identifier">locale</span>, <span class="ruby-identifier">default</span>, <span class="ruby-identifier">options</span>)
36:           <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">entry</span>.<span class="ruby-identifier">nil?</span>
37:             <span class="ruby-identifier">raise</span>(<span class="ruby-constant">I18n</span><span class="ruby-operator">::</span><span class="ruby-constant">MissingTranslationData</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">locale</span>, <span class="ruby-identifier">key</span>, <span class="ruby-identifier">options</span>))
38:           <span class="ruby-keyword kw">end</span>
39:         <span class="ruby-keyword kw">end</span>
40:         <span class="ruby-identifier">entry</span> = <span class="ruby-identifier">pluralize</span>(<span class="ruby-identifier">locale</span>, <span class="ruby-identifier">entry</span>, <span class="ruby-identifier">count</span>)
41:         <span class="ruby-identifier">entry</span> = <span class="ruby-identifier">interpolate</span>(<span class="ruby-identifier">locale</span>, <span class="ruby-identifier">entry</span>, <span class="ruby-identifier">values</span>)
42:         <span class="ruby-identifier">entry</span>
43:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <h3 class="section-bar">Protected Instance methods</h3>

      <div id="method-M002256" class="method-detail">
        <a name="M002256"></a>

        <div class="method-heading">
          <a href="#M002256" class="method-signature">
          <span class="method-name">deep_symbolize_keys</span><span class="method-args">(hash)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Return a new hash with all keys and nested keys converted to symbols.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M002256-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M002256-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/vendor/i18n-0.0.1/i18n/backend/simple.rb, line 207</span>
207:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">deep_symbolize_keys</span>(<span class="ruby-identifier">hash</span>)
208:           <span class="ruby-identifier">hash</span>.<span class="ruby-identifier">inject</span>({}) { <span class="ruby-operator">|</span><span class="ruby-identifier">result</span>, (<span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span>)<span class="ruby-operator">|</span>
209:             <span class="ruby-identifier">value</span> = <span class="ruby-identifier">deep_symbolize_keys</span>(<span class="ruby-identifier">value</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">Hash</span>
210:             <span class="ruby-identifier">result</span>[(<span class="ruby-identifier">key</span>.<span class="ruby-identifier">to_sym</span> <span class="ruby-keyword kw">rescue</span> <span class="ruby-identifier">key</span>) <span class="ruby-operator">||</span> <span class="ruby-identifier">key</span>] = <span class="ruby-identifier">value</span>
211:             <span class="ruby-identifier">result</span>
212:           }
213:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M002249" class="method-detail">
        <a name="M002249"></a>

        <div class="method-heading">
          <a href="#M002249" class="method-signature">
          <span class="method-name">default</span><span class="method-args">(locale, default, options = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Evaluates a <a href="Simple.html#M002249">default</a> translation. If the
given <a href="Simple.html#M002249">default</a> is a String it is used
literally. If it is a Symbol it will be translated with the given options.
If it is an Array the first translation yielded will be returned.
</p>
<p>
<em>I.e.</em>, <tt><a href="Simple.html#M002249">default</a>(locale, [:foo,
&#8216;<a href="Simple.html#M002249">default</a>&#8217;])</tt> will return
<tt><a href="Simple.html#M002249">default</a></tt> if <tt><a
href="Simple.html#M002242">translate</a>(locale, :foo)</tt> does not yield
a result.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M002249-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M002249-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/vendor/i18n-0.0.1/i18n/backend/simple.rb, line 112</span>
112:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">default</span>(<span class="ruby-identifier">locale</span>, <span class="ruby-identifier">default</span>, <span class="ruby-identifier">options</span> = {})
113:           <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">default</span>
114:             <span class="ruby-keyword kw">when</span> <span class="ruby-constant">String</span> <span class="ruby-keyword kw">then</span> <span class="ruby-identifier">default</span>
115:             <span class="ruby-keyword kw">when</span> <span class="ruby-constant">Symbol</span> <span class="ruby-keyword kw">then</span> <span class="ruby-identifier">translate</span> <span class="ruby-identifier">locale</span>, <span class="ruby-identifier">default</span>, <span class="ruby-identifier">options</span>
116:             <span class="ruby-keyword kw">when</span> <span class="ruby-constant">Array</span>  <span class="ruby-keyword kw">then</span> <span class="ruby-identifier">default</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">obj</span><span class="ruby-operator">|</span> 
117:               <span class="ruby-identifier">result</span> = <span class="ruby-identifier">default</span>(<span class="ruby-identifier">locale</span>, <span class="ruby-identifier">obj</span>, <span class="ruby-identifier">options</span>.<span class="ruby-identifier">dup</span>) <span class="ruby-keyword kw">and</span> <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">result</span>
118:             <span class="ruby-keyword kw">end</span> <span class="ruby-keyword kw">and</span> <span class="ruby-keyword kw">nil</span>
119:           <span class="ruby-keyword kw">end</span>
120:         <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">MissingTranslationData</span>
121:           <span class="ruby-keyword kw">nil</span>
122:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M002246" class="method-detail">
        <a name="M002246"></a>

        <div class="method-heading">
          <a href="#M002246" class="method-signature">
          <span class="method-name">init_translations</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M002246-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M002246-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/vendor/i18n-0.0.1/i18n/backend/simple.rb, line 78</span>
78:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">init_translations</span>
79:           <span class="ruby-identifier">load_translations</span>(<span class="ruby-operator">*</span><span class="ruby-constant">I18n</span>.<span class="ruby-identifier">load_path</span>)
80:           <span class="ruby-ivar">@initialized</span> = <span class="ruby-keyword kw">true</span>
81:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M002251" class="method-detail">
        <a name="M002251"></a>

        <div class="method-heading">
          <a href="#M002251" class="method-signature">
          <span class="method-name">interpolate</span><span class="method-args">(locale, string, values = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Interpolates values into a given string.
</p>
<pre>
  interpolate &quot;file {{file}} opened by \\{{user}}&quot;, :file =&gt; 'test.txt', :user =&gt; 'Mr. X'
  # =&gt; &quot;file test.txt opened by {{user}}&quot;
</pre>
<p>
Note that you have to double escape the <tt>\</tt> when you want to escape
the <tt>{{&#8230;}}</tt> key in a string (once for the string and once for
the interpolation).
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M002251-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M002251-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/vendor/i18n-0.0.1/i18n/backend/simple.rb, line 145</span>
145:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">interpolate</span>(<span class="ruby-identifier">locale</span>, <span class="ruby-identifier">string</span>, <span class="ruby-identifier">values</span> = {})
146:           <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">string</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">string</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">String</span>)
147: 
148:           <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">string</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:force_encoding</span>)
149:             <span class="ruby-identifier">original_encoding</span> = <span class="ruby-identifier">string</span>.<span class="ruby-identifier">encoding</span>
150:             <span class="ruby-identifier">string</span>.<span class="ruby-identifier">force_encoding</span>(<span class="ruby-constant">Encoding</span><span class="ruby-operator">::</span><span class="ruby-constant">BINARY</span>)
151:           <span class="ruby-keyword kw">end</span>
152: 
153:           <span class="ruby-identifier">result</span> = <span class="ruby-identifier">string</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-constant">MATCH</span>) <span class="ruby-keyword kw">do</span>
154:             <span class="ruby-identifier">escaped</span>, <span class="ruby-identifier">pattern</span>, <span class="ruby-identifier">key</span> = <span class="ruby-identifier">$1</span>, <span class="ruby-identifier">$2</span>, <span class="ruby-identifier">$2</span>.<span class="ruby-identifier">to_sym</span>
155: 
156:             <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">escaped</span>
157:               <span class="ruby-identifier">pattern</span>
158:             <span class="ruby-keyword kw">elsif</span> <span class="ruby-constant">INTERPOLATION_RESERVED_KEYS</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">pattern</span>)
159:               <span class="ruby-identifier">raise</span> <span class="ruby-constant">ReservedInterpolationKey</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">pattern</span>, <span class="ruby-identifier">string</span>)
160:             <span class="ruby-keyword kw">elsif</span> <span class="ruby-operator">!</span><span class="ruby-identifier">values</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">key</span>)
161:               <span class="ruby-identifier">raise</span> <span class="ruby-constant">MissingInterpolationArgument</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">pattern</span>, <span class="ruby-identifier">string</span>)
162:             <span class="ruby-keyword kw">else</span>
163:               <span class="ruby-identifier">values</span>[<span class="ruby-identifier">key</span>].<span class="ruby-identifier">to_s</span>
164:             <span class="ruby-keyword kw">end</span>
165:           <span class="ruby-keyword kw">end</span>
166: 
167:           <span class="ruby-identifier">result</span>.<span class="ruby-identifier">force_encoding</span>(<span class="ruby-identifier">original_encoding</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">original_encoding</span>
168:           <span class="ruby-identifier">result</span>
169:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M002239" class="method-detail">
        <a name="M002239"></a>

        <div class="method-heading">
          <a href="#M002239" class="method-signature">
          <span class="method-name">interpolate_with_deprecated_syntax</span><span class="method-args">(locale, string, values = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M002239-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M002239-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/i18n_interpolation_deprecation.rb, line 12</span>
12:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">interpolate_with_deprecated_syntax</span>(<span class="ruby-identifier">locale</span>, <span class="ruby-identifier">string</span>, <span class="ruby-identifier">values</span> = {})
13:           <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">string</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">string</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">String</span>)
14: 
15:           <span class="ruby-identifier">string</span> = <span class="ruby-identifier">string</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/%d|%s/</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">s</span><span class="ruby-operator">|</span>
16:             <span class="ruby-identifier">instead</span> = <span class="ruby-constant">DEPRECATED_INTERPOLATORS</span>[<span class="ruby-identifier">s</span>]
17:             <span class="ruby-constant">ActiveSupport</span><span class="ruby-operator">::</span><span class="ruby-constant">Deprecation</span>.<span class="ruby-identifier">warn</span> <span class="ruby-node">&quot;using #{s} in messages is deprecated; use #{instead} instead.&quot;</span>
18:             <span class="ruby-identifier">instead</span>
19:           <span class="ruby-keyword kw">end</span>
20: 
21:           <span class="ruby-identifier">interpolate_without_deprecated_syntax</span>(<span class="ruby-identifier">locale</span>, <span class="ruby-identifier">string</span>, <span class="ruby-identifier">values</span>)
22:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M002252" class="method-detail">
        <a name="M002252"></a>

        <div class="method-heading">
          <a href="#M002252" class="method-signature">
          <span class="method-name">load_file</span><span class="method-args">(filename)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Loads a single <a href="Simple.html#M002247">translations</a> file by
delegating to <a href="Simple.html#M002253">load_rb</a> or <a
href="Simple.html#M002254">load_yml</a> depending on the file extension and
directly merges the data to the existing <a
href="Simple.html#M002247">translations</a>. Raises <a
href="../UnknownFileType.html">I18n::UnknownFileType</a> for all other file
extensions.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M002252-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M002252-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/vendor/i18n-0.0.1/i18n/backend/simple.rb, line 175</span>
175:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">load_file</span>(<span class="ruby-identifier">filename</span>)
176:           <span class="ruby-identifier">type</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">extname</span>(<span class="ruby-identifier">filename</span>).<span class="ruby-identifier">tr</span>(<span class="ruby-value str">'.'</span>, <span class="ruby-value str">''</span>).<span class="ruby-identifier">downcase</span>
177:           <span class="ruby-identifier">raise</span> <span class="ruby-constant">UnknownFileType</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">type</span>, <span class="ruby-identifier">filename</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">respond_to?</span>(<span class="ruby-node">&quot;load_#{type}&quot;</span><span class="ruby-node">&quot;load_#{type}&quot;</span>)
178:           <span class="ruby-identifier">data</span> = <span class="ruby-identifier">send</span> <span class="ruby-node">&quot;load_#{type}&quot;</span><span class="ruby-node">&quot;load_#{type}&quot;</span>, <span class="ruby-identifier">filename</span> <span class="ruby-comment cmt"># TODO raise a meaningful exception if this does not yield a Hash</span>
179:           <span class="ruby-identifier">data</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">locale</span>, <span class="ruby-identifier">d</span><span class="ruby-operator">|</span> <span class="ruby-identifier">merge_translations</span>(<span class="ruby-identifier">locale</span>, <span class="ruby-identifier">d</span>) }
180:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M002253" class="method-detail">
        <a name="M002253"></a>

        <div class="method-heading">
          <a href="#M002253" class="method-signature">
          <span class="method-name">load_rb</span><span class="method-args">(filename)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Loads a plain Ruby <a href="Simple.html#M002247">translations</a> file.
eval&#8216;ing the file must yield a Hash containing translation data with
locales as toplevel keys.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M002253-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M002253-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/vendor/i18n-0.0.1/i18n/backend/simple.rb, line 184</span>
184:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">load_rb</span>(<span class="ruby-identifier">filename</span>)
185:           <span class="ruby-identifier">eval</span>(<span class="ruby-constant">IO</span>.<span class="ruby-identifier">read</span>(<span class="ruby-identifier">filename</span>), <span class="ruby-identifier">binding</span>, <span class="ruby-identifier">filename</span>)
186:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M002254" class="method-detail">
        <a name="M002254"></a>

        <div class="method-heading">
          <a href="#M002254" class="method-signature">
          <span class="method-name">load_yml</span><span class="method-args">(filename)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Loads a YAML <a href="Simple.html#M002247">translations</a> file. The data
must have locales as toplevel keys.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M002254-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M002254-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/vendor/i18n-0.0.1/i18n/backend/simple.rb, line 190</span>
190:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">load_yml</span>(<span class="ruby-identifier">filename</span>)
191:           <span class="ruby-constant">YAML</span><span class="ruby-operator">::</span><span class="ruby-identifier">load</span>(<span class="ruby-constant">IO</span>.<span class="ruby-identifier">read</span>(<span class="ruby-identifier">filename</span>))
192:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M002248" class="method-detail">
        <a name="M002248"></a>

        <div class="method-heading">
          <a href="#M002248" class="method-signature">
          <span class="method-name">lookup</span><span class="method-args">(locale, key, scope = [])</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Looks up a translation from the <a
href="Simple.html#M002247">translations</a> hash. Returns nil if eiher key
is nil, or locale, scope or key do not exist as a key in the nested <a
href="Simple.html#M002247">translations</a> hash. Splits keys or scopes
containing dots into multiple keys, i.e. <tt>currency.format</tt> is
regarded the same as <tt>%w(currency format)</tt>.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M002248-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M002248-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/vendor/i18n-0.0.1/i18n/backend/simple.rb, line 92</span>
 92:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">lookup</span>(<span class="ruby-identifier">locale</span>, <span class="ruby-identifier">key</span>, <span class="ruby-identifier">scope</span> = [])
 93:           <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">key</span>
 94:           <span class="ruby-identifier">init_translations</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">initialized?</span>
 95:           <span class="ruby-identifier">keys</span> = <span class="ruby-constant">I18n</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">:normalize_translation_keys</span>, <span class="ruby-identifier">locale</span>, <span class="ruby-identifier">key</span>, <span class="ruby-identifier">scope</span>)
 96:           <span class="ruby-identifier">keys</span>.<span class="ruby-identifier">inject</span>(<span class="ruby-identifier">translations</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">result</span>, <span class="ruby-identifier">k</span><span class="ruby-operator">|</span>
 97:             <span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">x</span> = <span class="ruby-identifier">result</span>[<span class="ruby-identifier">k</span>.<span class="ruby-identifier">to_sym</span>]).<span class="ruby-identifier">nil?</span>
 98:               <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span>
 99:             <span class="ruby-keyword kw">else</span>
100:               <span class="ruby-identifier">x</span>
101:             <span class="ruby-keyword kw">end</span>
102:           <span class="ruby-keyword kw">end</span>
103:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M002255" class="method-detail">
        <a name="M002255"></a>

        <div class="method-heading">
          <a href="#M002255" class="method-signature">
          <span class="method-name">merge_translations</span><span class="method-args">(locale, data)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Deep merges the given <a href="Simple.html#M002247">translations</a> hash
with the existing <a href="Simple.html#M002247">translations</a> for the
given locale
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M002255-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M002255-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/vendor/i18n-0.0.1/i18n/backend/simple.rb, line 196</span>
196:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">merge_translations</span>(<span class="ruby-identifier">locale</span>, <span class="ruby-identifier">data</span>)
197:           <span class="ruby-identifier">locale</span> = <span class="ruby-identifier">locale</span>.<span class="ruby-identifier">to_sym</span>
198:           <span class="ruby-identifier">translations</span>[<span class="ruby-identifier">locale</span>] <span class="ruby-operator">||=</span> {}
199:           <span class="ruby-identifier">data</span> = <span class="ruby-identifier">deep_symbolize_keys</span>(<span class="ruby-identifier">data</span>)
200: 
201:           <span class="ruby-comment cmt"># deep_merge by Stefan Rusterholz, see http://www.ruby-forum.com/topic/142809</span>
202:           <span class="ruby-identifier">merger</span> = <span class="ruby-identifier">proc</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-identifier">v1</span>, <span class="ruby-identifier">v2</span><span class="ruby-operator">|</span> <span class="ruby-constant">Hash</span> <span class="ruby-operator">===</span> <span class="ruby-identifier">v1</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-constant">Hash</span> <span class="ruby-operator">===</span> <span class="ruby-identifier">v2</span> <span class="ruby-value">? </span><span class="ruby-identifier">v1</span>.<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">v2</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">merger</span>) <span class="ruby-operator">:</span> <span class="ruby-identifier">v2</span> }
203:           <span class="ruby-identifier">translations</span>[<span class="ruby-identifier">locale</span>].<span class="ruby-identifier">merge!</span>(<span class="ruby-identifier">data</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">merger</span>)
204:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M002250" class="method-detail">
        <a name="M002250"></a>

        <div class="method-heading">
          <a href="#M002250" class="method-signature">
          <span class="method-name">pluralize</span><span class="method-args">(locale, entry, count)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Picks a translation from an array according to English pluralization rules.
It will pick the first translation if count is not equal to 1 and the
second translation if it is equal to 1. Other backends can implement more
flexible or complex pluralization rules.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M002250-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M002250-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/vendor/i18n-0.0.1/i18n/backend/simple.rb, line 128</span>
128:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">pluralize</span>(<span class="ruby-identifier">locale</span>, <span class="ruby-identifier">entry</span>, <span class="ruby-identifier">count</span>)
129:           <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">entry</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">entry</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>) <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">count</span>
130:           <span class="ruby-comment cmt"># raise InvalidPluralizationData.new(entry, count) unless entry.is_a?(Hash)</span>
131:           <span class="ruby-identifier">key</span> = <span class="ruby-identifier">:zero</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">count</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">entry</span>.<span class="ruby-identifier">has_key?</span>(<span class="ruby-identifier">:zero</span>)
132:           <span class="ruby-identifier">key</span> <span class="ruby-operator">||=</span> <span class="ruby-identifier">count</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">:one</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">:other</span>
133:           <span class="ruby-identifier">raise</span> <span class="ruby-constant">InvalidPluralizationData</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">entry</span>, <span class="ruby-identifier">count</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">entry</span>.<span class="ruby-identifier">has_key?</span>(<span class="ruby-identifier">key</span>)
134:           <span class="ruby-identifier">entry</span>[<span class="ruby-identifier">key</span>]
135:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M002247" class="method-detail">
        <a name="M002247"></a>

        <div class="method-heading">
          <a href="#M002247" class="method-signature">
          <span class="method-name">translations</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M002247-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M002247-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/vendor/i18n-0.0.1/i18n/backend/simple.rb, line 83</span>
83:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">translations</span>
84:           <span class="ruby-ivar">@translations</span> <span class="ruby-operator">||=</span> {}
85:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>